<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="开始" @click='st'>
        <input type="button" value="结束" @click='stop'>
        <p v-cloak>{{msg}}</p>
    </div>
</body>



<script>
    let vm = new Vue({
        el: '#app',
        data() {
            return {
                msg: '欢迎来到我的世界',
                id: null
            }
        },
        methods: {
            st() {
                if (this.id != null) return
                this.id = setInterval(() => {
                    let st = this.msg.substring(0, 1)
                    let end = this.msg.substring(1)
                    this.msg = end + st

                }, 100);
            },
            stop() {
                clearInterval(this.id)
                this.id = null

            }

        },
    })
</script>

</html>